package com.ylbh.modules.orderreturn.controller;

import com.ylbh.common.annotation.SysLog;
import com.ylbh.common.exception.NormalException;
import com.ylbh.common.pojo.orderreturn.dto.OrderReturnListDTO;
import com.ylbh.common.utils.CommonResult;
import com.ylbh.common.utils.PageUtils;
import com.ylbh.common.utils.Ref;
import com.ylbh.modules.orderreturn.service.OrderReturnService;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * 商城订单返佣
 */
@RestController
@RequestMapping("returnCommission")
public class OrderReturnController {

    @Autowired
    private OrderReturnService orderReturnService;

    @ApiOperation("商城订单返佣")
    @RequestMapping("queryOrderReturnList")
    @RequiresPermissions("returnCommission:queryOrderReturnList")
    public CommonResult<PageUtils> queryOrderReturnList(OrderReturnListDTO orderReturnListDTO) {
        PageUtils list = orderReturnService.queryOrderReturnList(orderReturnListDTO);
        return Ref.ok(list);
    }

    @SysLog("导出订单返佣")
    @ApiOperation("导出订单返佣")
    @RequestMapping("orderReturnExcel")
    @RequiresPermissions("returnCommission:orderReturnExcel")
    public CommonResult<Void> orderReturnExcel(HttpServletResponse response, HttpServletRequest request) throws NormalException {
        orderReturnService.orderReturnExcel(response, request);
        return Ref.ok();
    }

    @SysLog("导出商城推广佣金")
    @ApiOperation("导出商城推广佣金")
    @RequestMapping("promotionCommissionExcel")
    @RequiresPermissions("returnCommission:promotionCommissionExcel")
    public CommonResult<Void> promotionCommissionExcel(HttpServletResponse response, HttpServletRequest request) throws NormalException {
        orderReturnService.promotionCommissionExcel(response, request);
        return Ref.ok();
    }
}
